package com.ruoyi.business.base.controller;

import com.ruoyi.business.base.domain.AcceptStandardDetail;
import com.ruoyi.business.base.service.IAcceptStandardDetailService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 验收标准详情Controller
 *
 * @author lcy
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/base/standardDetail")
@Api(tags = "验收标准详情接口")
public class AcceptStandardDetailController extends BaseController {

    @Autowired
    private IAcceptStandardDetailService acceptStandardDetailService;

    /**
     * 查询验收标准详情列表
     */
    @RequiresPermissions("base:standardDetail:list")
    @GetMapping("/list")
    @Log(value = "查询验收标准详情列表")
    @ApiOperation("查询验收标准详情列表")
    public TableDataInfo list(AcceptStandardDetail acceptStandardDetail) {
        startPage();
        List<AcceptStandardDetail> list = acceptStandardDetailService.selectAcceptStandardDetailList(acceptStandardDetail);
        return getDataTable(list);
    }

    /**
     * 导出验收标准详情列表
     */
    @RequiresPermissions("base:standardDetail:export")
    @Log(title = "验收标准详情", businessType = BusinessType.EXPORT,value = "导出验收标准详情列表")
    @PostMapping("/export")
    @ApiOperation("导出验收标准详情列表")
    public void export(HttpServletResponse response, AcceptStandardDetail acceptStandardDetail) {
        List<AcceptStandardDetail> list = acceptStandardDetailService.selectAcceptStandardDetailList(acceptStandardDetail);
        ExcelUtil<AcceptStandardDetail> util = new ExcelUtil<AcceptStandardDetail>(AcceptStandardDetail.class);
        util.exportExcel(response, list, "验收标准详情数据");
    }

    /**
     * 获取验收标准详情详细信息
     */
    @RequiresPermissions("base:standardDetail:query")
    @GetMapping(value = "/{id}")
    @Log(value = "获取验收标准详情详细信息")
    @ApiOperation("获取验收标准详情详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(acceptStandardDetailService.selectAcceptStandardDetailById(id));
    }

    /**
     * 新增验收标准详情
     */
    @RequiresPermissions("base:standardDetail:add")
    @Log(title = "验收标准详情", businessType = BusinessType.INSERT,value = "新增验收标准详情")
    @PostMapping("/insert")
    @ApiOperation("新增验收标准详情")
    public AjaxResult add(@RequestBody AcceptStandardDetail acceptStandardDetail) {
        return toAjax(acceptStandardDetailService.insertAcceptStandardDetail(acceptStandardDetail));
    }

    /**
     * 修改验收标准详情
     */
    @RequiresPermissions("base:standardDetail:edit")
    @Log(title = "验收标准详情", businessType = BusinessType.UPDATE,value = "修改验收标准详情")
    @PutMapping("/update")
    @ApiOperation("修改验收标准详情")
    public AjaxResult edit(@RequestBody AcceptStandardDetail acceptStandardDetail) {
        return toAjax(acceptStandardDetailService.updateAcceptStandardDetail(acceptStandardDetail));
    }

    /**
     * 删除验收标准详情
     */
    @RequiresPermissions("base:standardDetail:remove")
    @Log(title = "验收标准详情", businessType = BusinessType.DELETE,value = "删除验收标准详情")
	@DeleteMapping("/delete/{ids}")
    @ApiOperation("删除验收标准详情")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(acceptStandardDetailService.deleteAcceptStandardDetailByIds(ids));
    }
}
